<?php
error_reporting(E_ALL ^ E_NOTICE);
// timezone
date_default_timezone_set('Asia/Shanghai');
// define root path,class path,app path,app name
define('ROOT_PATH', dirname(dirname(__DIR__)));
define('CLASS_PATH', ROOT_PATH . '/src');
define('APP_PATH', ROOT_PATH . '/test');
define('APP_NAME', basename(APP_PATH));
// require autoload
require_once CLASS_PATH . '/Liaiyong/Light/Autoloader.php';
// register classpath
Liaiyong\Light\Autoloader::register(CLASS_PATH);

//+++++++++++++++++++++++++++++++++++++++++++++++++//
//测试部分
use Liaiyong\Light\Action\Cgi;
use Liaiyong\Light\Core\App;
use Liaiyong\Light\Core\Action;
use Liaiyong\Light\Core\Error;
use Liaiyong\Light\Core\Model;
use Liaiyong\Light\Core\Service;

// class Test
class Test extends App {
    public function initialize() {
    }
}
class Index extends Cgi {
    /**
     * @var UserService
     */
    private $userService;
    /**
     * @Override
     */
    public function initialize() {
        parent::initialize();
        $this->userService = UserService::getInstance();
    }
    public function onGet() {
        global $CFG;
        throw Error::user_not_found();
        $user = $this->userService->get(1);
        $this->template->push('user', $user);
    }
}
class UserService extends Service {
    public function model() {
        return User::getInstance();
    }
}
class User extends Model {
    public function schema() {
        return 'hdkt';
    }
    public function table() {
        return 'users';
    }
    public function primary() {
        return 'uid';
    }
    public function columns() {
        return array(
            'uid' => 'uid',
            'name' => 'name',
            'loginid' => 'loginid',
            'password' => 'password'
        );
    }
}
//测试部分
//+++++++++++++++++++++++++++++++++++++++++++++++++//

// start app
Test::start(ROOT_PATH, APP_PATH);

// PHP END